package com.sunkai.string;

import java.util.Arrays;

public class TestString {
	
	private char[] value;
	
	public TestString(TestString testString) {
		this.value = testString.value;
	}
	public TestString(String string) {
		this.value = string.toCharArray();
	}
	
	public String toString() {
		return value.toString();
	}
	
	public char charAt(int index) throws Exception {
		if (index < 0) {
			throw new Exception(" < 0");
		}
		if (index > value.length - 1) {
			throw new Exception("***** String index out of bounds : " + index);
		}
		return value[index];
	}
	
	public String[]  split(String regex) {
		String[] result = new String[value.length];
		char[] regArr = new char[value.length];
		int count = 0;
		for (char c : value) {
			if (regex.charAt(0) == c) {
				regArr[count] = c;
				continue;
			}
		}
		return null;
	}
	
	public static void main(String[] args) throws Exception {
//		System.out.println("abcdef".charAt(6));
		TestString t = new TestString("abcdef");
		System.out.println(t.charAt(5));
		String[] temp = "a,,b,c,d,e,f".split(",.");
		System.out.println(Arrays.toString(temp));
		System.out.println(temp.length);
	}
}
